package vip.mengqin.diandezhun.ui.activity;
import android.view.View;
import android.widget.TextView;

import com.android.baselibrary.dialog.Comm_DialogFragment;
import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.baselibrary.responce.BaseResponce;
import com.android.baselibrary.tool.CommLoading;
import com.android.baselibrary.tool.CommToast;
import com.android.baselibrary.util.Util;
import com.android.baselibrary.view.Comm_HeadView;
import com.android.baselibrary.view.MultiStateView;
import butterknife.BindView;
import butterknife.OnClick;
import vip.mengqin.diandezhun.R;
import vip.mengqin.diandezhun.constant.URLConstants;
import vip.mengqin.diandezhun.manager.API_Manager;
import vip.mengqin.diandezhun.manager.UserManager;

/**
 * 关于我们
 */
public class AboutUsActivity extends BaseActivity {

    @BindView(R.id.multiplestatusView)
    MultiStateView multiplestatusView;
    @BindView(R.id.comm_title)
    Comm_HeadView comm_title;
    @BindView(R.id.tv_version)
    TextView tv_version;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_aboutus;
    }

    @Override
    protected void initView() {
        comm_title.setTitle("关于我们");
    }

    @Override
    protected void initData() {
        tv_version.setText("v " + Util.getVersionName(mContext));

    }

    @OnClick({R.id.ctv_xieyi, R.id.ctv_yingsi, R.id.ctv_zhuxiao})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ctv_xieyi:  //协议
                WebViewActivity.startActivity(mContext,"用户协议", URLConstants.URL_xieyi1);
                break;
            case R.id.ctv_yingsi:   //隐私
                WebViewActivity.startActivity(mContext,"隐私政策", URLConstants.URL_xieyi2);
                break;
            case R.id.ctv_zhuxiao:  //注销账号
                Comm_DialogFragment.showCommDialog(getSupportFragmentManager(), "", "确定注销吗", "确定", "取消", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        logoff();
                    }
                }, null);
                break;
        }
    }

    //获取
    private void logoff() {
        API_Manager.logoff(mContext, new OkHttpCallBack<BaseResponce<Object>>() {
            @Override
            public void onSuccess(BaseResponce<Object> baseResponce) {
                CommToast.showToast(mContext, "注销成功");
                UserManager.logout(mContext);
                finish();
            }

            @Override
            public void onFailure(BaseResponce<Object> baseResponce) {
                CommLoading.dismissLoading();
                CommToast.showToast(mContext, baseResponce.message);
            }
        });
    }

}
